﻿using Microsoft.EntityFrameworkCore;
using sys.datas.Models;

namespace sys.datas
{
    public class Context : DbContext
    {
        public DbSet<User> Users { get; set; }
        public DbSet<Role> DictTypes { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>().HasKey(c => c.UserCode);

            modelBuilder.Entity<Role>().HasKey(c => c.RoleCode);
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //这个地方需要整到配置文件里面，加密，压缩，让人看不懂就好
            string cs = "User ID=hmis;Password=hmis;Host=10.19.94.85;Port=5432;Database=hmisdb;Pooling=true;";
            optionsBuilder.UseNpgsql(cs);
        }
    }
}
